﻿@model IEnumerable<DPUWebPhet10.Models.TB_APPLICATION_STAFF>
@using DPUWebPhet10.Helpers
@{
    Layout = "~/Views/Shared/_Managementlayout.cshtml";
}

@{
    var grid = new WebGrid(Model, rowsPerPage: 10, ajaxUpdateContainerId: "worksajaxgrid", ajaxUpdateCallback: "ajaxUpdate_Callback");
    <!-- Content -->
    <div id="content">
        <div class="box">
            <!-- Box Head -->
            <div class="box-head">
                <h2 class="left">@DPUWebPhet10.Resources.Common.Common.grid_header_staff_000</h2>
                <div class="right">
                    <label>
                        search
                    </label>
                    <input type="text" class="field small-field" />
                    <input type="submit" class="button" value="search" />
                </div>
            </div>
            <div class="table" id="gridContent">
                @grid.GetHtml(
                                     tableStyle: "gridTable",
                                              headerStyle: "",
                                              footerStyle: "pagging",
                                              alternatingRowStyle: "",
                                             selectedRowStyle: "",
                                              rowStyle: "",
   columns: grid.Columns(
                        //grid.Column(header: "#", format: item => item.WebGrid.Rows.IndexOf(item) + 1),
            grid.Column(@DPUWebPhet10.Resources.Common.Common.LB008,
            format:
            @<text><input class="check-box" id="chkStaff" name="chkStaff" type="checkbox" value="@item.STAFF_ID" /></text>, canSort: false),

                 grid.Column("STAFF_NAME", @DPUWebPhet10.Resources.Staff.Staff.TABLE_HEADER_002, canSort: false, style: "px300"),
                 grid.Column("TB_M_LEVEL.LEVEL_NAME_TH", @DPUWebPhet10.Resources.Staff.Staff.TABLE_HEADER_001, canSort: false ,style: "px200"),
                 
            grid.Column(@DPUWebPhet10.Resources.Common.Common.LB007, format: (item) => Html.ActionLink(@DPUWebPhet10.Resources.Common.Common.LB007, "Edit", new { id = item.STAFF_ID }, new { @class = "ico edit" }), canSort: false)
             )

 )
            </div>
        </div>
    </div>
    <!-- End Content -->
    <!-- Sidebar -->
    <div id="sidebar">
        <!-- Box -->
        <div class="box">
            <!-- Box Head -->
            <div class="box-head">
                <h2>
                    Management</h2>
            </div>
            <!-- End Box Head-->
            <div class="box-content">
                <a href="/Staff/Create" class="add-button"><span>@DPUWebPhet10.Resources.Common.Common.LB025</span></a>
                <div class="cl">
                    &nbsp;</div>
                <p class="select-all">
                </p>
                <table>
                    <tr>
                        <td>
                            <input type="checkbox" class="checkbox" />
                        </td>
                        <td>
                            <label>
                                select all</label>
                        </td>
                        <td>
                            <img id="url_user" src="/images/del.gif" alt="" width="16px" height="16px" />
                        </td>
                        <td>
                            <label id="delete-staff">@DPUWebPhet10.Resources.Common.Common.LB008</label>
                        </td>
                    </tr>
                </table>
                <br />
                <!-- Sort -->
                <div class="sort">
                    <br />
                    <br />
                    <br />
                </div>
                <!-- End Sort -->
            </div>
        </div>
        <!-- End Box -->
    </div>
    <!-- End Sidebar -->


    
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/themes/base/css")
    <script type="text/javascript">
        $(document).ready(function () {

            $("#delete-staff").click(function () {

                if (confirm("Are you sure to delete records")) {
                    $('#gridContent table tr').each(function () {

                        if ($(this).find("input[id*='chkStaff']").length > 0) {
                            if ($(this).find("input[id*='chkStaff']")[0].checked == true) {
                                var id = $(this).find("input[id*='chkStaff']").attr("value");
                                var data = { ID: id };

                                var temp = $(this);
                                $.getJSON("/Staff/DeleteStaff", data, function (response) {
                                    if (response == true) {
                                        temp.remove();
                                    }
                                });
                            }
                        }
                    });
                }
            });


        });
    </script>
}
